//###############
//FILE : DirServersCommand.java
//WRITER : Daniel Lowengrub, daniel_i_l, 320687098
//EXERCISE : oop ex3 2011
//DESCRIPTION:
//See below
//###############
package oop.ex3.filemanager;


import java.util.ArrayList;
import oop.ex3.communication.SocketAddress;

/**
 * Implements the DIRSERVERS command as specified in the assignment.
 * @author daniel
 */
public class DirServersCommand extends UserCommand{
    private static final String DIRSERVERS_COMMAND = "DIRSERVERS";
    private NameServerDatabase _nameServerDb;

    /**
     * Construct a dirservers command.
     * @param connection The connection this command uses to talk to a NS.
     */
    public DirServersCommand(NameServerDatabase nameServerDb) {
        super(DIRSERVERS_COMMAND);
        _nameServerDb = nameServerDb;
    }


    @Override
    public boolean executeCommand(String command) {
        ArrayList<SocketAddress> nameServers = _nameServerDb.getAddressList();
        for (SocketAddress addr : nameServers)
            System.out.println(addr.getIp() + " " + addr.getPort());
        return true;
    }

}
